﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

using Pibby.Core.Opml;


namespace Pibby.Core
{
	public class PodcastCollectionImporter
	{
		public PodcastCollectionImporter()
		{
			this.Podcasts = new PodcastCollection();
		}

		public PodcastCollection Podcasts
		{
			get;
			set;
		}

		public void Load(TextReader stream)
		{
			this.Podcasts.Clear();

			OpmlDocument document = OpmlDocument.Load(stream);

			foreach (Outline outline in document.Outlines)
			{
				Uri feed = outline.XmlUrl;

				this.Podcasts.Add(new Podcast(outline.Text, feed));
			}
		}
	}
}
